<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:77:"/data/www/html/web2017/public_html/../application/web/view/user/user_reg.html";i:1498699822;s:78:"/data/www/html/web2017/public_html/../application/web/view/public/header2.html";i:1496220126;}*/ ?>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="hzcmgd">
    <title>树人学习</title>
    <link rel="icon" href="favicon.ico">

    <!-- Bootstrap core CSS -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="http://v3.bootcss.com/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="/static/pc/reg.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="http://v3.bootcss.com/assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="http://v3.bootcss.com/assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="/static/admin/js/layer/layer.js"></script>
    <script src="/static/admin/js/laypage/laypage.js"></script>
    <script src="/static/admin/js/laytpl/laytpl.js"></script>
    <link href="/static/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <style>
        .form-control{width: 100%;}
    </style>
</head>

<body>
<nav class="navbar navbar-fixed-top navbar-inverse">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>
            <a  href="#"><img src="/static/pc/image/logo.png" style="height: 50px;padding-right: 20px;"></a>
        </div>
        <div id="navbar" class="collapse navbar-collapse" style="font-size:16px;">
            <ul class="nav navbar-nav">
                <li><a href="<?php echo url('index/index'); ?>">首页</a></li>
                <li><a href="<?php echo url('user/center'); ?>">个人主页</a></li>
                <!--<li><a href="#contact">Contact</a></li>-->
            </ul>
            <div class="nav navbar-nav navbar-right">
                <!--<form class="navbar-form navbar-left">-->
                <!--<div class="form-group">-->
                <!--<input type="text" class="form-control" placeholder="搜索内容">-->
                <!--</div>-->
                <!--<button type="submit" class="btn btn-default">确定</button>-->
                <!--</form>-->
                <ul class="nav navbar-nav navbar-right">
                    <li class="active"><a href="<?php echo url('article/user_index'); ?>">用户中心</a></li>
                    <?php if($is_login==1): ?>
                    <li><a href="<?php echo url('user/quitlogin'); ?>">退出</a></li> <?php endif; ?>
                    <!--<li class="dropdown">-->
                    <!--<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">方法 <span class="caret"></span></a>-->
                    <!--<ul class="dropdown-menu">-->
                    <!--<li><a href="#">订单</a></li>-->
                    <!--<li><a href="#">嗯嗯</a></li>-->
                    <!--<li><a href="#">尺寸</a></li>-->
                    <!--<li role="separator" class="divider"></li>-->
                    <!--<li><a href="#">嗷嗷</a></li>-->
                    <!--</ul>-->
                    <!--</li>-->
                </ul>
            </div>
        </div>
        <!-- /.nav-collapse -->
    </div>
    <!-- /.container -->
</nav>
<!-- /.navbar -->


<div class="container container-form"  style="width: 1200px; padding: 0 50px;">

    <div class="page-header">
        <h2>个人注册</h2>
    </div>

    <form class="form-horizontal"   name="add" id="add" method="post" action="<?php echo url('user/create'); ?>">




        <div class="form-group">
            <label for="name" class="col-sm-3 control-label" id="xm">手机号码</label>
            <div class="col-sm-5">
                <input class="form-control" type="text" id="mobile" name="mobile" id="mobile" value="">
            </div>
            <div class="col-sm-2">
                <input id="yzm" type="button" style="padding:5px 10px;border: 0px; background: #2FAB87;border-radius: 5px;color: #fff;"  onclick="get_code(this);" value="获取验证码" ></input>
            </div>
        </div>

        <div class="form-group" >
            <label  class="col-sm-3 control-label">验证码</label>
            <div class="col-sm-5">
                <input class="form-control" type="text" name="code" id="code" value="">
            </div>
            <p class="help-block"></p>
        </div>

        <div class="form-group" >
            <label  class="col-sm-3 control-label">登录密码</label>
            <div class="col-sm-5">
                <input class="form-control" type="password" name="password" id="password" value="">
            </div>
            <p class="help-block"></p>
        </div>
        <div class="form-group" >
            <label  class="col-sm-3 control-label">确认密码</label>
            <div class="col-sm-5">
                <input class="form-control" type="password" name="password1" id="password1" value="">
            </div>
            <p class="help-block"></p>
        </div>


        <div class="form-group" >
            <label  class="col-sm-3 control-label">用户昵称</label>
            <div class="col-sm-5">
                <input class="form-control" type="text" name="nickname" id="nickname" value="">
            </div>
            <p class="help-block"></p>
        </div>

        <div class="form-group" >
            <label  class="col-sm-3 control-label">真实姓名</label>
            <div class="col-sm-5">
                <input class="form-control" type="text" name="nickname" id="realname" value="">
            </div>
            <p class="help-block"></p>
        </div>


        <div class="form-group">
            <div class="col-sm-offset-4 col-sm-10">
                <a href="javascript:;" onclick="reg(); return false;"> <button type="submit" class="btn btn-default btn-cmgd">注册</button></a>
            </div>
        </div>
    </form>


</div><!--/.container-->



<script type="text/javascript">
    var countdown=60;

    function settime(val) {
        if (countdown == 0) {
            val.removeAttribute("disabled");
            val.value="免费获取验证码";
            $('#yzm').css('background',"#2FAB87");
            countdown = 60;
            return;
        } else {
            val.setAttribute("disabled", true);
            val.value="重新发送(" + countdown + ")";
            $('#yzm').css('background',"#ccc");
            countdown--;
        }
        setTimeout(function() {
            settime(val)
        },1000)
    }


    function get_code(val){
       mobile =  $('#mobile').val();
        if(!(/^1[3|4|5|7|8][0-9]\d{4,8}$/.test(mobile))){
            layer.msg('手机号码格式有误',{icon:5,time:1500,shade: 0.1,});
            return false;
        }else{

            $.post('<?php echo url("base/index/get_sms_code"); ?>',
                    {mobile:mobile},
                    function(data){
                        console.log(data);
                        if(data.code==1){
                            layer.msg('验证码发送成功，请注意查收',{icon:-1,time:1500,shade: 0.1,});
                        }else{
                            layer.msg('验证码发送失败',{icon:-1,time:2500,shade: 0.1,});
                        }
                    });


            settime(val);
        }

    }



    function reg(){

        var password1 =  document.getElementById('password1').value;
        var password =  document.getElementById('password').value;
        var mobile =  document.getElementById('mobile').value;
        var code =  document.getElementById('code').value;
        var nickname =  document.getElementById('nickname').value;
        var realname =  document.getElementById('realname').value;

        if(''==mobile){

            layer.msg('手机号码不能为空',{icon:5,time:1500,shade: 0.1,});
            return false;
        }

        if( password==''){
            layer.msg('密码不能为空',{icon:5,time:1500,shade: 0.1,});
            return false;
        }

        if( password!=password1){
            layer.msg('两次输入的密码不同，请确认！',{icon:5,time:1500,shade: 0.1,});
            return false;
        }

        if(''==code){

            layer.msg('验证码不能为空',{icon:5,time:1500,shade: 0.1,});
            return false;
        }
        if(''==nickname){

            layer.msg('昵称不能为空',{icon:5,time:1500,shade: 0.1,});
            return false;
        }

      if(''==realname){

                layer.msg('真实姓名不能为空',{icon:5,time:1500,shade: 0.1,});
                return false;
            }


        $.post('<?php echo url("user/user_reg"); ?>',
                {code:code,mobile:mobile,password:password,nickname:nickname,realname:realname},
                function(data){
                    console.log(data);
                    if(data.code==1){

                        layer.msg('注册成功', {icon: 6,time:1500,shade: 0.2}, function(index){
                                layer.close(index);
                            });


                        setTimeout(function() {
                            window.location.href="<?php echo url('index/index'); ?>";
                        },1500)

                    }else{
                        layer.msg('注册失败', {icon: 5,time:1500,shade: 0.2}, function(index){
                            layer.close(index);
                        });

                    }
                });
        return false;
    }
</script>



<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="http://v3.bootcss.com/assets/js/ie10-viewport-bug-workaround.js"></script>
<script src="http://v3.bootcss.com/examples/offcanvas/offcanvas.js"></script>
</body>
</html>
